#include <iostream>
#include <string>
int main()
{
	//=
	std::string aa = "abcd";
	std::string bb = aa;

	std::cout << "aa=" << aa << std::endl;
	std::cout << "bb=" << bb << std::endl;
	/*
	string的连接：
	string &operator+=(const string &s);//把字符串s连接到当前字符串的结尾
	string &append(const char *s);            //把c类型字符串s连接到当前字符串结尾
	string &append(const char *s,int n);//把c类型字符串s的前n个字符连接到当前字符串结尾
	string &append(const string &s);    //同operator+=()
	string &append(const string &s,int pos,int n);//把字符串s中从pos开始的n个字符连接到当前字符串的结尾
	string &append(int n,char c);        //在当前字符串结尾添加n个字符c
	string &append(const_iterator first,const_iterator last);//把迭代器first和last之间的部分连接到当前字符串的结尾
	*/
	std::string cc = aa + bb;
	std::cout << "cc=" << cc << std::endl;

	std::string dd = "abcdef";
	std::cout << "dd=" << dd << std::endl;
	//add '.' to the end of string
	dd.push_back('.');
	std::cout << "dd=" << dd << std::endl;
	//add " - ladeng"(string) to the end of string
	dd.append(" - ladeng");
	std::cout << "dd=" << dd << std::endl;
	//make the string(dd), to "dreadms"
	dd.assign("dreams");
	std::cout << "dd=" << dd << std::endl;
	//get a parameter
	std::cout << dd[2] << std::endl;
	//if at(n),will throw exception out_of_range
	std::cout << dd.at(3)<< std::endl;

	//get string from command line
	#if 0
	//get stream from cin to s, default end with '\n'
	std::string ee;
	getline(std::cin , ee);
	std::cout << "ee=" << ee << std::endl;
	getline(std::cin , ee, '!');	
	std::cout << "ee=" << ee << std::endl;
	#endif

	std::string ff = "abcdfeg";
	std::cout << "capacity=" << ff.capacity() << std::endl;
	std::cout << "max_size=" << ff.max_size() << std::endl;
	std::cout << "size=" << ff.size() << std::endl;
	std::cout << "length=" << ff.length() << std::endl;
	ff = "";
	//if string is NULL, return 1;if string isn't NULL, return 0
	std::cout << "empty=" << ff.empty() << std::endl;
	//std::cout << "resize=" << ff.resize() << std::endl;

	/*
	string的比较：
	bool operator==(const string &s1,const string &s2)const;//比较两个字符串是否相等
	运算符">","<",">=","<=","!="均被重载用于字符串的比较；
	int compare(const string &s) const;//比较当前字符串和s的大小
	int compare(int pos, int n,const string &s)const;//比较当前字符串从pos开始的n个字符组成的字符串与s的大小
	int compare(int pos, int n,const string &s,int pos2,int n2)const;//比较当前字符串从pos开始的n个字符组成的字符串与s中pos2开始的n2个字符组成的字符串的大小
	*/
	std::string gg = "abcde";
	std::string gg_1 = "abc";
	//std::cout << "gg("<<gg<<") compare gg_1("<<")"<<gg_1<<std::endl;
	std::cout << gg.compare(gg_1) << std::endl;

	/*
	int compare(const char *s) const;
	int compare(int pos, int n,const char *s) const;
	int compare(int pos, int n,const char *s, int pos2) const;
	compare函数在>时返回1，<时返回-1，==时返回0   
	*/
}
